<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // let a = 10
        // function fn() {
        //     // 函数的内部能够拿到外部的变量
        //     console.log(a);
        // }
        // fn()

        // function fn2(){
        //     let b = 20;
        // }
        // console.log(b); // Uncaught ReferenceError: b is not defined
        var outletiable = "我是最外层变量";
        function outFun() {
            var inletiable = "内层变量";

            function innerFun() {
                console.log(inletiable);
            }
            innerFun();
        }
        console.log(outletiable); // 我是最外层变量
        outFun(); // 内层变量
        console.log(inletiable); // Uncaught ReferenceError: inletiable is not defined
        innerFun(); // Uncaught ReferenceError: innerFun is not defined

    </script>
</body>

</html>